#ifndef MEMBERSHIPHISTORYMANAGERTEST_HPP
#define MEMBERSHIPHISTORYMANAGERTEST_HPP

#include <gtest/gtest.h>
#include "MembershipHistoryManager.h"

TEST(MembershipHistorySerialization, ShoudWorkAsExpected)
{
  MembershipHistory one("1", "1", "1", static_cast<time_t>(10002), static_cast<time_t>(10002));
  MembershipHistory two("2", "2", "2", static_cast<time_t>(10003), static_cast<time_t>(10003));
  MembershipHistoryManager manager;
  manager.insert(one);
  manager.insert(two);
  ASSERT_EQ(2, manager.size());

  manager.serialize("./membership_history.csv");
  manager.deserialize("./membership_history.csv");

  ASSERT_EQ(2, manager.size());
  const MembershipHistory *gotOne = manager.historyById(one.id());
  const MembershipHistory *gotTwo = manager.historyById(two.id());

  ASSERT_TRUE(gotOne != 0);
  ASSERT_TRUE(gotTwo != 0);
  ASSERT_EQ(one, *gotOne);
  ASSERT_EQ(two, *gotTwo);
}

#endif // MEMBERSHIPHISTORYMANAGERTEST_HPP